<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 鸡兔同笼 -->
    <script>
        for (chicken = 0; chicken < 30; chicken++) {
            for (duck = 0; duck < 30; duck++) {
                if ((2 * chicken + 4 * duck) == 80 && (chicken + duck) == 30) {
                    document.write(`鸡有${chicken}只<br>`);
                    document.write(`鸭有${duck}只`);
                }
            }
        }
    </script>
    <!-- 买水果 -->
    <script>
        for (apple = 0; apple < 100; apple++) {
            for (pear = 0; pear < 100; pear++) {
                for (peach = 0; peach < 100; peach++) {
                    if ((3 * apple + 2 * pear + 1 * peach) == 200 && (apple + pear + peach) == 100) {
                        console.log(`苹果有${apple}个`);
                        console.log(`梨有${pear}个`);
                        console.log(`桃有${peach}个`);
                    }
                }
            }
        }
    </script>
    <!-- 实现f(n)=n! -->
    <script>
        function f(n) {
            if (n == 1) {
                return 1;
            } else {
                return n * f(n - 1);
            }
        }
        console.log(f(10));
    </script>
</body>

</html>